package com.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import com.dao.UserDao;
import com.po.User;
import com.service.UserService;

@Service("userService")
public class UserServiceImpl extends BaseServiceImpl implements UserService {
	@Resource
	private UserDao userDao;
	
	public UserServiceImpl(){
		System.out.println("user service init");
	}
	@Override
	public void SaveUser(User userForm) {
		// TODO Auto-generated method stub
		User user=new User();
		BeanUtils.copyProperties(userForm, user);
		int a= userDao.Save(user);
		System.out.println(a);
	}
	@Override
	public User getUserById(Integer id) {
		// TODO Auto-generated method stub
		return userDao.getById(id);
	}
	@Override
	public List<User> userlist() {
		// TODO Auto-generated method stub
		return userDao.findAll();
	}
	@Override
	public User Update(User user) {
		// TODO Auto-generated method stub
		userDao.Update(user);
		return getUserById(user.getId());
	}
	@Override
	public void DelUser(int id) {
		// TODO Auto-generated method stub
		userDao.Del(id);
	}
	
}
